Skip to content

feat: Canvases in iframes#656

Draft
stravo1 wants to merge 9 commits into
frappe:developfrom
stravo1:canvas-iframe
Draft

feat: Canvases in iframes#656
stravo1 wants to merge 9 commits into
frappe:developfrom
stravo1:canvas-iframe

Conversation

@stravo1

@stravo1 stravo1 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Render each responsive canvas breakpoint inside an isolated iframe.

This makes the editor canvas behave more like the published page by separating its DOM, styles, events, and client scripts from the Builder interface.

  • Styles and scripts no longer interfere with the editor UI
  • Each breakpoint has its own isolated document and runtime
  • Component, and page client scripts can be emulated in the canvas
  • Canvas interactions operate across iframe boundaries

This does not guarantee safe script execution as scripts can still cross the iframe boundary and reach parent window, but we do achieve total DOM isolation.

Screen.Recording.2026-07-02.at.11.51.21.PM.mp4
Screen.Recording.2026-07-02.at.11.51.53.PM.mp4
Screenshot 2026-07-02 at 11 52 50 PM

stravo1 added 6 commits July 2, 2026 02:47
Centralize cross-frame DOM and drag handling so canvas interactions use a
single coordinate conversion and listener lifecycle.

- consolidate resize, spacing, block movement, panning, and insertion drags
- manage event forwarding and drop-zone cleanup per iframe registration
- remove obsolete outer overlay and unused frame document state
- preserve editable targets when forwarding iframe events
- fix HTML editor double-click and context-menu dispatch inside frames
- initialize fonts after teleported canvas elements are mounted
- keep iframe styles, classes, and theme attributes synchronized
- consolidate async client-script cleanup and error handling
- prevent history from remaining paused when insertion targets disappear
- remove leftover event and history debug logging

Verification:
- production frontend build passes
- touched iframe modules pass focused TypeScript checking
- browser and Cypress testing left for manual verification
Execute attached page-level JavaScript and CSS inside each rendered
breakpoint iframe.

- apply page CSS continuously in attachment order
- run page JavaScript through the existing restricted or unrestricted
  canvas sandbox
- expose iframe document, window, events, and page_data where allowed
- reuse the existing Run, Stop, and Refresh canvas controls
- recreate frames when scripts, page data, settings, or pages change
- preserve script ordering when loading page client scripts
- synchronize attached scripts after create, attach, update, rename,
  remove, and reorder operations
- keep the existing execute_block_scripts_in_editor field for
  compatibility while updating its label to cover all client scripts
- retain existing block and component script behavior
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.53%. Comparing base (34f902c) to head (db411ed).
⚠️ Report is 19 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #656      +/-   ##
===========================================
+ Coverage    56.19%   56.53%   +0.34%     
===========================================
  Files           34       34              
  Lines         4077     4109      +32     
===========================================
+ Hits          2291     2323      +32     
  Misses        1786     1786              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant